<?php
/**
 * @var News
 */
$news = $model;

Yii::app()->clientScript->registerScriptFile('/ueditor/editor_config.js');
Yii::app()->clientScript->registerScriptFile('/ueditor/editor_all_min.js');
Yii::app()->clientScript->registerCssFile("/ueditor/themes/default/ueditor.css");
Yii::app()->clientScript->registerCss("x", '#ui-datepicker-div {z-index:999}');
Yii::app()->clientScript->registerCss("x2", '.ui-datepicker { width: 17em; padding: .2em .2em 0; z-index: 9999 !important; }');
?>
<div class="form">

<?php 
$form=$this->beginWidget('CActiveForm', array(
	'id'=>'news-form',
	'enableAjaxValidation'=>false,
)); ?>

	<p class="note">
		标有 <span class="required">*</span> 的为必填项.
	</p>

	<?php echo $form->errorSummary($model); ?>
	

	<div class="row">
		<?php echo $form->labelEx($model,'date'); ?>
		<?php
		$this->widget ( 'zii.widgets.jui.CJuiDatePicker', array (
				'attribute' => 'date',
				'language' => 'zh_cn',
				'name' => 'News[date]',
				'options' => array (
						'showAnim' => 'fold',
						'showOn' => 'both',
						'minDate' => 'new Date()',
						'dateFormat' => 'yy-mm-dd' 
				),
				'htmlOptions' => array (
					'style' => 'height:18px',
					'readonly' => true,
					'class' => $news->getError('date') ? 'error' : ''
				),
				'value' => $model->date
		) ); 
		?>
		<?php echo $form->error($model,'date'); ?>
	</div>

	<div class="row">
	
<?php 

$news_category = NewsCategory::model()->findAll();

$tags = array();

foreach($news_category as $cat) {
    $tags[$cat->id] = $cat->ClassName;
}

?>
		<?php include dirname(__FILE__) . '/cat.php';?>
		<?php echo $form->labelEx($model,'category_id'); ?>
		<?php echo $form->dropDownList($model,'category_id', $t); ?>
		<?php echo $form->error($model,'category_id'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'title'); ?>
		<?php echo $form->textField($model,'title',array('size'=>60,'maxlength'=>512)); ?>
		<?php echo $form->error($model,'title'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'content'); ?>
		<?php echo $form->error($model,'content'); ?>

		<script type="text/plain" id="editor" style="width: 600px;"><?php echo $news->content;?></script>
		<script>
	        new UE.ui.Editor().render('editor');
	    </script>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? '创建' : '保存'); ?>
	</div>

<?php $this->endWidget(); ?>

</div>
<!-- form -->
